package mc0241;

import java.util.Scanner;

public class Main {

	// 最小表示法
	public static int func(String a) {
		int n = a.length();
		int k = 0;
		int i = 0;
		int j = 1;

		while (k < n && i < n && j < n) {
			if (a.charAt((i + k) % n) == a.charAt((j + k) % n)) {
				++k;
			} else {
				if (a.charAt((i + k) % n) > a.charAt((j + k) % n))
					++i;
				else
					++j;
				k = 0;
				if (i == j)
					i++;
			}
		}
		i = Math.min(i, j);
		return i;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		String s2 = sc.nextLine();
		int a = func(s1);
		int b = func(s2);
		String a1 = s1.substring(a) + s1.substring(0, a);
		String b1 = s2.substring(b) + s2.substring(0, b);
		if(a1.equals(b1)) {
			System.out.println("Yes");
			System.out.println(a1);
		}else {
			System.out.println("No");
		}
		
	}

}
